<template>
  <div>
    <el-dialog :title="title" :visible.sync="uploadVisible" :append-to-body="true" @close="close()"
               style="text-align: center">
      <el-upload
        class="upload-demo"
        drag
        action="/api/flow/v1/deploy"
        :headers="headers"
        :on-success="onSuccess"
        multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">只能上传xml文件，且不超过10MB</div>
      </el-upload>
    </el-dialog>
  </div>
</template>

<script>
    import { getToken } from '@/utils/auth'
    export default {
        name: "uploadFlowFile",
        props:{
            uploadVisible:{default:()=>{ return false }}
        },
        data(){
            return {
                title:"流程部署",
                headers:{
                    'authorization':'Bearer ' + getToken()
                }
            }
        },
        methods:{
            close(){
                this.$emit('closeupload')
            },
            onSuccess(response, file, fileList){
                console.log(response)
                if(response.code=="0000"){
                    this.$message({
                        message: '操作成功',
                        type: 'success',
                        duration: 1000,
                        onClose:() =>{
                            this.close()
                        }})
                }
            },
        }
    }
</script>

<style scoped>

</style>
